<#assign object = doc.object>
package ${object.package}.gwt.client.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.gwt.beansbinding.core.client.util.AbstractBean;


<#if object.description[0]??>
/** 
${object.description} 
*/
</#if>
public class ${object.name} extends AbstractBean {
	  public Long id;
	  public Long getId() {
	    return id;
	  }
	  public void setId(Long id) {
	  	Long oldValue = this.id;
	    this.id = id;
	    firePropertyChange("id", oldValue, this.id);
	  }
	  public Date creationDate;
	  public void setCreationDate(Date creationDate) {
	  	Date oldValue = this.creationDate;
	    this.creationDate = creationDate;
		firePropertyChange("creationDate", oldValue, this.creationDate);
	  }
	  public Date getCreationDate() {
	    return this.creationDate;
	  }
	  public Date updateDate;
	  public void setUpdateDate(Date updateDate) {
	    Date oldValue = this.updateDate;
	    this.updateDate = updateDate;
		firePropertyChange("updateDate", oldValue, this.updateDate);
	  }
	  public Date getUpdateDate() {
	    return this.updateDate;
	  }
	<#list object.attributes.enum as att>
	  <#if att.description[0]??>
	  /** ${att.description} */
	  </#if>
	  public enum ${att.@class} {
	  <#list att.element as value>
	    <#if value.@description[0]??>
	    /** ${value.@description} */
	    </#if>
	    ${value.@name}<#if value_has_next>,<#else>;</#if>
	  </#list>
	    /** @return Null, or the result of valueOf() */
	    public static ${att.@class} valueOfNullSafe(String value) {
		  if (value != null)
			  return valueOf(value);
		  return null; 
	    }
	  }
	</#list>
	
	<#list object.attributes?children as att>
	  <#if att?node_name != "set" && att?node_type == "element">
	    <#if att?node_name == "xml">
	  //public ${att.@class[0]!att.@name?cap_first} ${att.@name};
	    <#elseif att?node_name == "date" || att?node_name == "datetime">
	  public Date ${att.@name};
	    <#elseif att?node_name == "enum">
	  public ${att.@class} ${att.@class?uncap_first};
	    <#elseif att?node_name == "object">
	  //public ${att.@class} ${att.@class?uncap_first};
	  public Long ${att.@class?uncap_first}Id;
	    <#elseif att?node_name == "html" || att?node_name == "string">
	  public String ${att.@name};
	    <#elseif att?node_name == "boolean">
	  public Boolean ${att.@name};
	    <#else>
	  public ${att?node_name?cap_first} ${att.@name};
	    </#if>
	  </#if>
	</#list>
	
	  /**
	  * This method will set default values for:<br>
	<#list object.attributes?children as att>
	  <#if att.default[0]??>
	  * ${att.@name!att.@class} - ${att.@default};<br>
	  </#if>
	</#list>
	  */
	  public ${object.name}() {
	    super();
	<#list object.attributes?children as att>
	  <#if att.@default[0]??>
	    <#if att?node_name == "boolean">
	    set${att.@name?cap_first}(Boolean.<#if att.@default == "true">TRUE<#else>FALSE</#if>);
	    <#elseif att?node_name == "string">
	    set${att.@name?cap_first}("${att.@default}");
	    <#elseif att?node_name == "integer" || att?node_name == "long">
	    set${att.@name?cap_first}(${att.@default});
	    <#elseif att?node_name == "enum">
	    set${att.@class}(${att.@class}.${att.@default});
	    <#else>
	    error - undefined default ${att?node_name}
	    </#if>
	  </#if>
	</#list>
	  }
	
	<#list object.attributes?children as att>
	 <#if att?node_name != "set" && att?node_type == "element">
	  <#if att.description[0]??>
	  /** ${att.description} **/
	  </#if>
	  <#if att?node_name == "boolean">
	  public void set${att.@name?cap_first}(Boolean ${att.@name}) {
	  	Boolean oldValue = this.${att.@name};
	    this.${att.@name} = ${att.@name};
		firePropertyChange("${att.@name}", oldValue, this.${att.@name});
	  }
	  <#elseif att?node_name == "date" || att?node_name == "datetime">
	  public void set${att.@name?cap_first}(Date ${att.@name}) {
	    Date oldValue = this.${att.@name};
	    this.${att.@name} = ${att.@name};
		firePropertyChange("${att.@name}", oldValue, this.${att.@name});
	  }
	  <#elseif att?node_name == "xml">
	  //public void set${att.@name?cap_first}(${att.@class[0]!att.@name?cap_first} ${att.@name}) {
		//No need for any dirty setting, this is done just before persisting using dirty${att.@name?cap_first}Hash.
	  //  this.${att.@name} = ${att.@name};
	  //}
	  <#elseif att?node_name == "object">
	  //public void set${att.@class}(${att.@class} ${att.@class?uncap_first}) throws LazyException {
	     //The ${att.@class} field is lazy loaded, first invoke the getter:
	  //  if (this.${att.@class?uncap_first} == null)
	  //	  get${att.@class}();
	  //  this.${att.@class?uncap_first} = ${att.@class?uncap_first};
	  //  if (this.${att.@class?uncap_first} != null)
	  //    this.${att.@class?uncap_first}Id = ${att.@class?uncap_first}.getId();
	  //  else
	  //    this.${att.@class?uncap_first}Id = null;
	 // }
	  
	  public void set${att.@class}Id(Long ${att.@class?uncap_first}Id) {
	  	Long oldValue = this.${att.@class?uncap_first}Id;
	    this.${att.@class?uncap_first}Id = ${att.@class?uncap_first}Id;
		firePropertyChange("${att.@class?uncap_first}Id", oldValue, this.${att.@class?uncap_first}Id);
	  }
	  <#elseif att?node_name == "enum">
	  public void set${att.@class}(${att.@class} ${att.@class?uncap_first}) {
	  	${att.@class} oldValue = this.${att.@class?uncap_first};
	    this.${att.@class?uncap_first} = ${att.@class?uncap_first};
		firePropertyChange("${att.@class?uncap_first}", oldValue, this.${att.@class?uncap_first});
	  }
	  <#else>
	  public void set${att.@name?cap_first}(${att?node_name?cap_first} ${att.@name}) {
	    ${att?node_name?cap_first} oldValue = this.${att.@name};
	   	this.${att.@name[0]!att.@class?uncap_first} = ${att.@name};
		firePropertyChange("${att.@name}", oldValue, this.${att.@name}); 
	  }
	  </#if>
	
	  <#if att.description[0]??>
	  /** ${att.description} **/
	  </#if>
	    <#if att?node_name == "boolean">
	  public Boolean get${att.@name?cap_first}() {
	    <#elseif att?node_name == "date" || att?node_name == "datetime">
	  public Date get${att.@name?cap_first}() {
	    <#elseif att?node_name == "xml">
	    <#elseif att?node_name == "enum">
	  public ${att.@class} get${att.@class}() {
	    <#elseif att?node_name == "object">
	   public Long get${att.@class}Id() {
	    <#else>
	  public ${att?node_name?cap_first} get${att.@name?cap_first}() {
	    </#if>
	    <#if att?node_name == "object">
	  	return ${att.@class?uncap_first}Id;
	  }
	  	<#elseif att?node_name == "xml">
	    <#else>
	    return ${att.@name[0]!att.@class?uncap_first};
	  }
	    </#if>
	 </#if>
	</#list>
	
}
